/**************************************************************************************
 * Copyright (C) 2007 Esper Team. All rights reserved.                                *
 * http://esper.codehaus.org                                                          *
 * ---------------------------------------------------------------------------------- *
 * The software in this package is published under the terms of the GPL license       *
 * a copy of which has been included with this distribution in the license.txt file.  *
 **************************************************************************************/
package pl.edu.agh.soa.monitoring.benchmark;

import java.io.Serializable;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;

/**
 * The actual event.
 * The time property (ms) is the send time from the client sender, and can be used for end to end latency providing client(s)
 * and server OS clocks are in sync.
 * The inTime property is the unmarshal (local) time (ns).
 *
 * @author Alexandre Vasseur http://avasseur.blogspot.com
 */
public class MarketData implements Serializable{

    public final static int SIZE = Symbols.SIZE + Double.SIZE + Integer.SIZE + Long.SIZE;
    static {
        System.out.println("MarketData event = " + SIZE + " bit = " + SIZE/8 + " bytes");
        System.out.println("  100 Mbit/s <==> " + (int) (100*1024*1024/SIZE/1000) + "k evt/s");
        System.out.println("    1 Gbit/s <==> " + (int) (1024*1024*1024/SIZE/1000) + "k evt/s");
    }

    private  String ticker;
    private  double price;
    private  int volume;

	private long time;//ms
    private final long inTime;

    public MarketData(String ticker, double price, int volume) {
        this();
        this.ticker = ticker;
        this.price = price;
        this.volume = volume;
    }

    public MarketData() {
    	this.inTime = System.nanoTime();
    }
    public String getTicker() {
		return ticker;
	}

	public void setTicker(String ticker) {
		this.ticker = ticker;
	}

	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	public int getVolume() {
		return volume;
	}

	public void setVolume(int volume) {
		this.volume = volume;
	}

	public long getTime() {
		return time;
	}

	public void setTime(long time) {
		this.time = time;
	}

	public long getInTime() {
		return inTime;
	}
	
    public String toString() {
        return ticker+" : "+time+" : "+price+" : "+volume;
    }

    public Object clone() throws CloneNotSupportedException {
        return new MarketData(ticker, price, volume);
    }
}


